package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbReportInFlow;
import com.ruoyi.supplier.service.ITbReportInFlowService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日营业进账流水Controller
 * 
 * @author oliver.li
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/supplier/reportInFlow")
public class TbReportInFlowController extends BaseController
{
    @Autowired
    private ITbReportInFlowService tbReportInFlowService;

    /**
     * 查询每日营业进账流水列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportInFlow:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbReportInFlow tbReportInFlow)
    {
        startPage();
        List<TbReportInFlow> list = tbReportInFlowService.selectTbReportInFlowList(tbReportInFlow);
        return getDataTable(list);
    }

    /**
     * 导出每日营业进账流水列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportInFlow:export')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbReportInFlow tbReportInFlow)
    {
        List<TbReportInFlow> list = tbReportInFlowService.selectTbReportInFlowList(tbReportInFlow);
        ExcelUtil<TbReportInFlow> util = new ExcelUtil<TbReportInFlow>(TbReportInFlow.class);
        return util.exportExcel(list, "每日营业进账流水数据");
    }

    /**
     * 获取每日营业进账流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportInFlow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbReportInFlowService.selectTbReportInFlowById(id));
    }

    /**
     * 新增每日营业进账流水
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportInFlow:add')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbReportInFlow tbReportInFlow)
    {
        return toAjax(tbReportInFlowService.insertTbReportInFlow(tbReportInFlow));
    }

    /**
     * 修改每日营业进账流水
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportInFlow:edit')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbReportInFlow tbReportInFlow)
    {
        return toAjax(tbReportInFlowService.updateTbReportInFlow(tbReportInFlow));
    }

    /**
     * 删除每日营业进账流水
     */
    @PreAuthorize("@ss.hasPermi('supplier:reportInFlow:remove')")
    @Log(title = "每日营业进账流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbReportInFlowService.deleteTbReportInFlowByIds(ids));
    }
}
